<template>
	<MkDrawer ref="mkDrawerRef" @submit="submitFn" v-model:isEdit="isEdit">
		<MkCardForm>
			<el-row>
				<MkInput v-model="form.name" label="检验套餐分组名称" :isEdit="isEdit" />
				<MkInput v-model="form.group" label="互扫分组" :isEdit="isEdit" />
				<MkInput v-model="form.defaultPackage" label="互扫默认分组" :isEdit="isEdit" />
				<MkInput v-model="form.prefix" label="自编号前缀" :isEdit="isEdit" />
				<MkInput v-model="form.autoNumber" label="是否启用自定自编号" :isEdit="isEdit" />
				<MkInput v-model="form.directAudit" label="未检验能否直接审核" :isEdit="isEdit" />
				<MkInput v-model="form.sort" label="排序" :isEdit="isEdit" />
				<el-form-item label="是否启用" :isEdit="isEdit">
					<el-switch v-model="form.isEnabled" size="large" active-text="启用" inactive-text="禁用" />
				</el-form-item>

			</el-row>

		</MkCardForm>

	</MkDrawer>
</template>
<script lang='ts' setup>
import { useEditScripts } from '/@/hooks/useEditScripts'
import { ElMessage } from 'element-plus'
/**
 * 表单数据
 */
const form = ref({
	id: '',
	name: '',
	group: '',
	defaultPackage: '',
	prefix: '',
	autoNumber: '',
	directAudit: '',
	sort: '',
	isEnabled: false,
});

// emits
const emits = defineEmits(['onSuccess','returnData']);
const onSuccessEmit = () => {
	emits('onSuccess')
}

const {
	isEdit,
	openDrawerFn,
	closeDrawerFn,
	mkDrawerRef,
	// submitFn
} = useEditScripts<any>()
//数据赋值
const DataAssignment = (row: any) => {
	if (row) {
		form.value = JSON.parse(JSON.stringify(row))
	}
};

const submitFn = () =>{
	ElMessage({
    message: '保存成功',
    type: 'success',
  })
	isEdit.value = false
	closeDrawerFn()
	DisplayData()
}
//修改后的数据
const DisplayData = ()=>{
	emits('returnData',form)
}
onMounted(() => {

})

defineExpose({
	openDrawerFn, closeDrawerFn,DataAssignment
})


</script>